<?
	include "../db.php";
	session_start();

	if(isset($_GET['username']))
		$username = $_GET['username'];



	if(isset($_SESSION['username']))
		$username1 = $_SESSION['username'];



	if($username == $username1)
	{

	$query = "select * from login where username = '$username'";
	$result = mysql_query($query);

	if($result)
	{
		$rows = mysql_fetch_assoc($result);
		$category = $rows['category'];
		$query_category = "select * from $category where username = '$username'";
		$result_category = mysql_query($query_category);
		if($result_category)
		{

	
		$rows_category = mysql_fetch_assoc($result_category);



?>



<head>
<link href = "../css/border_style_rounded.css" type = "text/css" rel = "stylesheet" />
</head>

		<form action='profile_update_handler.php' method = 'post' enctype='multipart/form-data'>
		<div class="divTable">
		        <div class="headRow">
        		        <div class="divCell_info">Username : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_username' id = 'username' onblur = 'return valid(this.id)' value = '<?echo $rows_category['username'];?>' disabled /></div>
        		        <div class="divCell_error"><label id = 'lbl_username'></label></div>
        		</div>
            		<div class="divRow">
        		        <div class="divCell_info">Email : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_email' id = 'email' onblur ='return valid(this.id)' onkeyup = 'return mail()' value = '<?echo $rows_category['email'];?>' disabled /></div>
        		        <div class="divCell_error"><label id = 'lbl_email'></label></div>
        		</div>
            		<div class="divRow">
        		        <div class="divCell_info">Password : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'password' name = 'txt_password' id = 'password' onblur = 'return valid(this.id)' onkeyup = 'return pwd()' value = '<?echo $rows_category['password'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_password'></label></div>
        		</div>
            		<div class="divRow">
        		        <div class="divCell_info">Confirm Password : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'password' name = 'txt_cpassword' id = 'cpassword' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['password'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_cpassword'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">Full Name : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_fullname' id = 'fullname' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['name'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_fullname'></label></div>
        		</div>



            		<div class="divRow">
        		        <div class="divCell_info">Address : </div>
        		        <div class="divCell_input"><textarea class = 'rounded' type = 'text' name = 'txt_address' id = 'address' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' rows = '4' cols = '30'><?echo $rows_category['address'];?></textarea></div>
        		        <div class="divCell_error"><label id = 'lbl_address'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">City : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_city' id = 'city' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['city'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_city'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">State : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_state' id = 'state' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['state'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_state'></label></div>
        		</div>
            		<div class="divRow">
        		        <div class="divCell_info">Contact : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_contact' id = 'contact' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['contact'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_contact'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">Avatar : </div>
        		        <div class="divCell_input"><input class = 'filerounded' type = 'file' name = 'img_avatar' id = 'avatar' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' /></div>
        		        <div class="divCell_error"><label id = 'lbl_avatar'></label></div>
        		</div>

          		<div class="divRow">
        		        <div class="divCell_info">Logo : </div>
        		        <div class="divCell_input"><input class = 'filerounded' type = 'file' name = 'img_logo' id = 'logo' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' /></div>
        		        <div class="divCell_error"><label id = 'lbl_logo'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">Website / Blog : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_web_page' id = 'web_page' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['web_page'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_web_page'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">Fax : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_fax' id = 'fax' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['fax'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_fax'></label></div>
        		</div>

            		<div class="divRow">
        		        <div class="divCell_info">Principal : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_principal' id = 'principal' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['principal'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_principal'></label></div>
        		</div>


            		<div class="divRow">
        		        <div class="divCell_info">Principal Email : </div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'text' name = 'txt_principal_email' id = 'principal_email' onblur = 'return valid(this.id)' onkeyup = 'return cpwd()' value = '<?echo $rows_category['principal_email'];?>' /></div>
        		        <div class="divCell_error"><label id = 'lbl_principal_email'></label></div>
        		</div>
            		<div class="divRow">
        		        <div class="divCell_info"></div>
        		        <div class="divCell_input"><input class = 'rounded' type = 'submit' name = 'txt_submit' id = 'submit' onblur = 'return valid()' value = 'Update' /></div>
        		        <div class="divCell_error"><label id = 'lbl_cpassword'></label></div>
        		</div>
      		</div>
		<input type = "hidden" name = "type" value = "<?echo $category;?>" />
		<input type = "hidden" name = "username" value = "<?echo $username;?>" />
		<input type = "hidden" name = "image" value = "<?echo $rows_category['image'];?>" />
		<input type = "hidden" name = "image_logo" value = "<?echo $rows_category['logo'];?>" />
		</form>


<?
	}
		else echo "table";
	}
		else echo "login";
	}
	else
	{
		header("location:../login/login.php?msg=please don't try this again");
	}

?>


<?
	if(isset($_GET['msg']))
	{
		$msg = $_GET['msg'];
	}
	else
	{
		$msg = "";
	}
	echo $msg;
?>
